<?php
namespace tp5_lib\wechat\model;

use think\Model;

class WechatUserTokenModel extends Model
{
    protected $table="wechat_user_token";
    public function install()
    {
        $table=$this->db()->getTable();
        $sql="CREATE TABLE IF NOT EXISTS `$table` (
            `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
            `source` varchar(20) NOT NULL,
            `time` int(11) NOT NULL,
            `access_token` varchar(100) NOT NULL,
            `expires_in` int(11) NOT NULL,
            `refresh_token` varchar(100) NOT NULL,
            `openid` varchar(40) NOT NULL,
            `scope` varchar(40) NOT NULL,
            `unionid` varchar(40) NOT NULL
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        $this->db()->execute($sql);
    }
}
